package org.cloudie.docs.editor.client.icons.desktop;

import org.cloudie.docs.editor.client.commands.generic.ExplorerWindowOpenVirtualFolderCommand;
import org.cloudie.docs.editor.client.commands.generic.VirtualEntryMoveCommand;
import org.cloudie.docs.editor.client.events.CommandEvent;
import org.cloudie.docs.editor.client.widgets.DesktopIcon;

import com.google.gwt.user.client.ui.Widget;

public class FolderDesktopIcon extends DesktopIcon {

  
  public FolderDesktopIcon(String id, String label, String image) {
	super(id, label, image, "Open " + label, null);
	this.command = new ExplorerWindowOpenVirtualFolderCommand(id);
  }

  @Override
  public boolean allowsDropping(Widget receiver) {
  	return true;
  }

  @Override
  public boolean allowsDropping() {
  	return true;
  }
  
  @Override
  public boolean acceptsReceives(Widget dropped, boolean isFinal) {
	if (dropped instanceof DesktopIcon) {
      return true;
	}
	return false;
  }

  @Override
  public boolean acceptsReceives() {
  	return true;
  }

  @Override
  public void onReceive(Widget dropped, int x, int y) {
    DesktopIcon di = (DesktopIcon) dropped;
    CommandEvent.fire(new VirtualEntryMoveCommand(
        di.getId(), this.getId(), x, y, -1));
  }
  
}
